package com.promis.party.ui.home.homebanner.mywork;

import android.app.Dialog;
import android.content.Context;
import android.graphics.Rect;
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager;
import android.widget.TextView;

import com.promis.party.R;
import com.promis.util.ScreenUtils;

/**
 * Created by jidanbo on 2018/1/24.
 */

public class MyWorkDialog extends Dialog {

//    private TextView txtvTitle;
//    private TextView txtvContent;
    private TextView txtvButtonOne;
    private TextView txtvButtonTwo;

    private OnButtonClickListener onConfirmClickListener;

    public MyWorkDialog(Context context) {
        super(context, R.style.Theme_OverlayDialog);

        Rect rect = ScreenUtils.getScreenRect(getContext());
        setCanceledOnTouchOutside(true);
        getWindow().getDecorView().setPadding(0, 0, 0, 0);
        WindowManager.LayoutParams a = getWindow().getAttributes();
        a.width = rect.width() * 2 / 3;
        a.height = WindowManager.LayoutParams.WRAP_CONTENT;
        a.gravity = Gravity.CENTER;
        getWindow().setAttributes(a);

        setContentView(R.layout.dialog_my_work);

        txtvButtonOne = (TextView) findViewById(R.id.dialog_my_work_txtv_one);
        txtvButtonTwo = (TextView) findViewById(R.id.dialog_my_work_txtv_two);

        initListener();
    }

    private void initListener() {
        txtvButtonOne.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (onConfirmClickListener != null) onConfirmClickListener.onButtonOneClick(v);
                dismiss();
            }
        });

        txtvButtonTwo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (onConfirmClickListener != null) onConfirmClickListener.onButtonTwoClick(v);
                dismiss();
            }
        });
    }

//    public void setTitle(String alertTitle) {
//        txtvTitle.setText(alertTitle);
//    }
//
//    public void setAlert(String alertText) {
//        txtvContent.setText(alertText);
//    }

    public void setButtonOne(String btnText) {
        txtvButtonOne.setText(btnText);
    }

    public void setButtonTwo(String btnText) {
        txtvButtonTwo.setText(btnText);
    }

    public void setOnConfirmClickListener(final OnButtonClickListener onConfirmClickListener) {
        this.onConfirmClickListener = onConfirmClickListener;
    }

    public static class OnButtonClickListener {
        public void onButtonOneClick(View view) {}

        public void onButtonTwoClick(View view) {}
    }

    public void initDate(String title,String content,String button1Name,String button2Name){
//        txtvTitle.setText(title);
//        txtvContent.setText(content);
        txtvButtonOne.setText(button1Name);
        txtvButtonTwo.setText(button2Name);
    }
}
